﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Enterprise.Model;
using Enterprise.Utility;
using Enterprise.Bll.Contract;

namespace Enterprise.Web
{
    public partial class NewsDetail : System.Web.UI.Page
    {
        private static string _templateFileName = "News.html";
        private int newsID;
        private string[] cssFileUrlList;
        INews inews = Factorys.GetBllImplement.GetNews();
        protected void Page_Load(object sender, EventArgs e)
        {
            cssFileUrlList = SiteUtility.GetCssFileUrlList();
            newsID = Request.GetQ("NewsID").GetInt(0);
            DataBinds();
        }
        protected void DataBinds()
        {
            IEnumerable<News> news =ModelConvertHelper<News>.ToModels(inews.GetNewsDetail(newsID));
            var obj = new VelocityHelper("~/Template", System.Text.Encoding.GetEncoding("UTF-8"));
            obj.Put("CssFileUrlList", cssFileUrlList);
            obj.Put("resRootPath", SiteUtility.GetResRootPath());
            obj.Put("news",news.ToArray()[0]);
            obj.Display(_templateFileName);
        }
    }
}
